cmake_minimum_required(VERSION 2.8)

#-------------------------------------------------------------------------------------------------
#------------------ include directories of ATOMISM and set source files-----------------------------
#-------------------------------------------------------------------------------------------------

message(STATUS "\n----------From src/Base/CMakeLists.txt----------")

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMake_FindModules )


IF(PYTHON)
  find_package(PythonLibs REQUIRED)
  include_directories(${PYTHON_INCLUDE_DIRS})
ENDIF(PYTHON)

IF( PYTHON )
  find_package(Boost COMPONENTS system python  program_options filesystem REQUIRED )
ELSEIF( NOT PYTHON )
  find_package(Boost COMPONENTS system  program_options filesystem REQUIRED )
ENDIF( PYTHON )

include_directories(${Boost_INCLUDE_DIRS})

FIND_PACKAGE(Eigen3 )
if( !EIGEN3_INCLUDE_DIR )
   set( ${EIGEN3_INCLUDE_DIR}  ${CMAKE_CURRENT_SOURCE_DIR}/eigen3/Eigen/ 
  			       ${CMAKE_CURRENT_SOURCE_DIR}/eigen3/Eigen/src
       )
ENDIF( !EIGEN3_INCLUDE_DIR )

include_directories(${EIGEN3_INCLUDE_DIR})

FILE(GLOB BASE_SRC  ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/muparser_v2_2_3/*.cpp)

FILE(GLOB BASE_HEADER  ${CMAKE_CURRENT_SOURCE_DIR}/*.h   ${CMAKE_CURRENT_SOURCE_DIR}/muparser_v2_2_3/*.h)

INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/  ${CMAKE_CURRENT_SOURCE_DIR}/muparser_v2_2_3 )

#-------------------------------------------------------------------------------------------------
#------------------ compile library base --------------------------------------------------------
#-------------------------------------------------------------------------------------------------

add_library ( base   SHARED ${BASE_SRC}  ${BASE_SRC}) 
            
IF( NOT COVERAGE )
   SET_TARGET_PROPERTIES( base PROPERTIES COMPILE_FLAGS -fPIC )
   SET_TARGET_PROPERTIES( base PROPERTIES COMPILE_FLAGS -O3 )
ENDIF(NOT COVERAGE )

TARGET_LINK_LIBRARIES( base ${PYTHON_LIBRARIES}  ${Boost_LIBRARIES} )
set_target_properties(base PROPERTIES  SUFFIX .so)

SET( ATOMISM_BASE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/muparser_v2_2_3 )
SET( ATOMISM_BASE_LIBRARIES    base  ${PYTHON_LIBRARIES}  ${Boost_LIBRARIES} )

foreach(next_ITEM ${BASE_SRC})
   file(APPEND ${LAUNCHER_FILE} "#include<${next_ITEM}>\n" )
endforeach(next_ITEM ${BASE_SRC})

INSTALL(FILES  ${BASE_HEADER} DESTINATION ${CMAKE_INSTALL_PREFIX}/include )

